import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false

import {
  Lazyload,
  Swipe,
  SwipeItem,
  CountDown,
  Toast,
  Popup,
  Cell,
  CellGroup,
  Checkbox,
  CheckboxGroup,
  Overlay,
  Loading,
  Empty,
  Progress,
  Slider
} from "vant";

Vue.use(Lazyload);
// 轮播
Vue.use(Swipe);
Vue.use(SwipeItem);
// 倒计时
Vue.use(CountDown);
// 轻提示
Vue.use(Toast);
Vue.use(Popup);
Vue.use(Cell);
Vue.use(CellGroup);
// 复选
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Overlay);
// 空状态 加载
Vue.use(Empty);
Vue.use(Loading);
// 进度条
Vue.use(Progress);
// 滑块
Vue.use(Slider);
import "./assets/font/iconfont.css";

import "amfe-flexible";

// 动态修改title
router.beforeEach((to, from, next) => {
  window.scrollTo(0, 0)
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next();
})

// 全局顶部组件
import navTop from "./components/base/navTop.vue";
Vue.component("nav-top", navTop);
// 全局书籍横向排序组件
import bookItem from "./components/base/bookItem.vue";
Vue.component("book-item", bookItem);
// 全局纵向书籍列表组件
import bookList from "./components/base/bookList.vue";
Vue.component("book-list", bookList);
// 全局有tab的书籍列表组件
import bookRank from "./components/base/bookRank.vue";
Vue.component("book-rank", bookRank);

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')